package esa.isoc.statistics;

import java.util.StringTokenizer;

public class OldEntry implements Entry {
	public double hours;
	private double totalHours;
	public long time;
	public double fraction;
	public String comment;

	public OldEntry(StringTokenizer st) {
		String hoursSt = st.nextToken();
		if (hoursSt != null && hoursSt.length() > 0) {
			hours = Double.parseDouble(hoursSt.trim());
		}
		if (st.hasMoreElements() == false) return;
		
		String totalHoursSt = st.nextToken();
		if (totalHoursSt != null && totalHoursSt.length() > 0) {
			totalHours = Double.parseDouble(totalHoursSt.trim());
		}
		if (st.hasMoreElements() == false) return;

		String timeSt = st.nextToken();
		if (timeSt != null && timeSt.length() > 0) {
			time = Long.parseLong(timeSt.trim());
		}
		if (st.hasMoreElements() == false) return;

		String fractionSt = st.nextToken();
		if (fractionSt != null && fractionSt.length() >0 ) {
			fraction = Double.parseDouble(fractionSt.trim());
		}
		if (st.hasMoreElements() == false) return;

		String comment = st.nextToken();
		if (comment != null && comment.length() > 0 && comment.equals("0") == false) {
			this.comment =comment;
		}
	}

	@Override
	public double getHours() {
		if (totalHours> 0) return totalHours;
		return hours;
	}

	@Override
	public long getTime() {
		return time;
	}

	@Override
	public double getFraction() {
		return fraction;
	}

	@Override
	public String getComment() {
		return comment;
	}

	@Override
	public String toString() {
		return "OldEntry [getHours()=" + getHours() + ", getTime()="
				+ getTime() + ", getFraction()=" + getFraction()
				+ ", getComment()=" + getComment() + "]";
	}

	
}
